package com.feicheng.common.result;

import com.alibaba.fastjson.JSONObject;
import com.feicheng.common.constant.Constant;

public class ResultInfo extends JSONObject {

	private static final long serialVersionUID = -1412532553323522836L;

	private ResultInfo() {
        this.put(Constant.RESULT.STATUS, Constant.RESULT.SUCCESS);
    }

    private ResultInfo(Object data) {
        this.put(Constant.RESULT.STATUS, Constant.RESULT.SUCCESS);
        this.put(Constant.RESULT.DATA, data);
    }

    private ResultInfo(String status, String message) {
        this.put(Constant.RESULT.STATUS, status);
        this.put(Constant.RESULT.MESSAGE, message);
    }


    public static ResultInfo success() {
        return new ResultInfo();
    }

    public static ResultInfo success(Object data) {
        return new ResultInfo(data);
    }

    public static ResultInfo fail(String message) {
        return new ResultInfo(Constant.RESULT.FAIL, message);
    }
    
    public static ResultInfo bindingFail(String message) {
        return new ResultInfo(Constant.RESULT.BIND_FAIL, message);
    }

    public static ResultInfo loginFail() {
        return new ResultInfo(Constant.RESULT.LOGIN_FAIL, null);
    }

    public static ResultInfo error(String message) {
        return new ResultInfo(Constant.RESULT.ERROR, "");
    }
}